package com.san.hkhospital.config;

import com.san.hkhospital.intercepter.LoginInterceptor;
import org.springframework.boot.SpringBootConfiguration;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.CorsRegistry;
import org.springframework.web.servlet.config.annotation.EnableWebMvc;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

/**
 * ClassName:MyMvcConfig
 * PackageName:com.san.hkhospital.config
 * Description:
 *
 * @Author:yy
 * @CreatedAt:2024/11/12 14:08
 */

@SpringBootConfiguration
public class MyWebMvcConfig implements WebMvcConfigurer {
//    @Override
//    public void addInterceptors(InterceptorRegistry registry) {
//        registry.addInterceptor(new LoginInterceptor()).addPathPatterns("/**").excludePathPatterns("/**/login", "/**/register","/test/*");
//    }

    @Override
    public void addCorsMappings(CorsRegistry registry) {
        registry.addMapping("/**")
                .allowedOrigins("http://localhost:8080")
                .allowedMethods("PUT", "DELETE","POST","GET","OPTIONS")
                .allowedHeaders("*")
                .allowCredentials(true).maxAge(3600);

    }




}
